from string import digits
chosen = "xxxx"
f_bulls = []
my_dict = {}
for i in digits:
my_dict.update({i:{
"excepect":[]
}})
def make_chosen(chosen,obj=None):
if type(obj) != int:
return ''.join(list(map(lambda x: "x" if x[0] not in obj else x[1], enumerate(chosen))))
else:
return ''.join(list(map(lambda x: "x" if x[0] == obj else x[1], enumerate(chosen))))
def int_input():
return list(map(lambda a: int(a), input().split(" ")))
def guess(chosen: str, old=None,my_digits = digits[5:] + digits[:5]):
for i in my_digits:
if chosen.count("x") == 0: break
place = chosen.index("x") if place not in my_dict[i]["excepect"] and i != old and i not in chosen:
chosen = chosen.replace("x",i,1)
if chosen.count("x") > 0:
chosen = chosen.replace("x",chosen[f_bulls[0]])
return chosen
def sure_bull(b1, chosen, f_bull: list):
copy = chosen
bulls = f_bull
i = 0
while i < 4:
if i in f_bulls:
i += 1
continue
chosen = make_chosen(chosen,i)
chosen = guess(chosen , copy[i])
print(chosen)
[b,_] = int_input()
if b == 4:
return "Out",[0,1,2,3]
if b < b1:
bulls.append(i)
i += 1
chosen = copy
return chosen,bulls
b_old, c_old = 0, 0
while b_old != 4:
chosen = guess(chosen)
print(chosen)
[b_new, c_new] = int_input()
if b_new == 4: break
if b_new == 0 or b_new <= b_old:
for i,val in enumerate(chosen):
if i not in f_bulls:
my_dict[val]["excepect"].append(i)
if b_new > b_old:
chosen,bulls = sure_bull(b_new, chosen, f_bulls)
if chosen == "Out": break
f_bulls.extend(bulls)
f_bulls = list(set(f_bulls))
chosen = make_chosen(chosen,f_bulls)
b_old, c_old = b_new, c_new
else:
chosen = make_chosen(chosen,f_bulls)
1143B - Nirvana | 1285A - Mezo Playing Zoma |
919B - Perfect Number | 894A - QAQ |
1551A - Polycarp and Coins | 313A - Ilya and Bank Account |
1469A - Regular Bracket Sequence | 919C - Seat Arrangements |
1634A - Reverse and Concatenate | 1619C - Wrong Addition |
1437A - Marketing Scheme | 1473B - String LCM |
1374A - Required Remainder | 1265E - Beautiful Mirrors |
1296A - Array with Odd Sum | 1385A - Three Pairwise Maximums |
911A - Nearest Minimums | 102B - Sum of Digits |
707A - Brain's Photos | 1331B - Limericks |
305B - Continued Fractions | 1165B - Polycarp Training |
1646C - Factorials and Powers of Two | 596A - Wilbur and Swimming Pool |
1462B - Last Year's Substring | 1608B - Build the Permutation |
1505A - Is it rated - 2 | 169A - Chores |
765A - Neverending competitions | 1303A - Erasing Zeroes |